home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2006 May / PCWMAY06.iso / Software / Freeware / First Page 2006 3.00 / fp2006-final-3.00-setup.exe / {app} / Iscripts / Forms Misc / no-dupes.izs < prev    next >
Text File  |  2005-09-28  |  4KB  |  176 lines

  1. <!NOWIZARD>
  2.  
  3. <!TITLE>No Duplicates
  4. <!/TITLE>
  5.  
  6. <!DESCRIPTION>Prevents you from selecting the same choice when choosing from two different pulldown menus. <!/DESCRIPTION> 
  7.  
  8. <!CATEGORY>Forms<!/CATEGORY>
  9.  
  10. <!SCRIPT>
  11. <!-- START OF SCRIPT -->
  12.  
  13.  
  14. <!-- HOW TO INSTALL NO DUPLICATES:
  15.  
  16.   1.  Copy code into the HEAD section of document
  17.   2.  Put last coding into the BODY section of document  -->
  18.  
  19. <!-- STEP ONE: Add code into HEAD section of document  -->
  20.  
  21. <HEAD>
  22.  
  23. <SCRIPT LANGUAGE="JavaScript">
  24. <!-- Original:  Denis Dijon (ddijon@hotmail.com) -->
  25. <!-- Web Site:  http://213.177.134.20 -->
  26.  
  27.  
  28.  
  29. <!-- Begin
  30. var OptLstTxt = new Array;
  31. var OptLstVal = new Array;
  32. var OptLen = 0;
  33. function NoDupl(SelObjFrom, SelObjTo) {
  34. var OldToVal = SelObjTo.options[SelObjTo.selectedIndex].value;
  35. if (OptLen == 0) {
  36. OptLen = SelObjFrom.length;
  37. for (var i = 1; i < OptLen; i++) {
  38. OptLstTxt[i] = SelObjFrom.options[i].text;
  39. OptLstVal[i] = SelObjFrom.options[i].value;
  40.    }
  41. }
  42. var j = 1;
  43. for (var i = 1; i < OptLen; i++) {
  44. if (OptLstVal[i] != SelObjFrom.options[SelObjFrom.selectedIndex].value) {
  45. if (j == SelObjTo.length) {
  46. SelObjTo.options[j] = new Option(OptLstTxt[i]);
  47. }
  48. else {
  49. SelObjTo.options[j].text = OptLstTxt[i];
  50. }
  51. SelObjTo.options[j].value = OptLstVal[i];
  52. if (OptLstVal[i] == OldToVal) {
  53. SelObjTo.selectedIndex = j;
  54. }
  55. j++;
  56.    }
  57. }
  58. if (SelObjTo.length > j)
  59. SelObjTo.options[(SelObjTo.length - 1)] = null;
  60. }
  61. //  End -->
  62. </script>
  63.  
  64. </HEAD>
  65.  
  66. <!-- STEP TWO: Add code into BODY section of document  -->
  67.  
  68. <BODY>
  69.  
  70. <form method="POST" name="MForm">
  71. Try to select the same color:
  72. <br>
  73. <select name="Color_1" onChange="NoDupl(this,document.MForm.Color_2)">
  74. <option selected value=''>Select your first prefered color</option>
  75. <option value='R'>Red</option>
  76. <option value='J'>Yellow</option>
  77. <option value='G'>Green</option>
  78. <option value='B'>Blue</option>
  79. </select>
  80. <select name="Color_2" onChange="NoDupl(this,document.MForm.Color_1)">
  81. <option selected value=''>Select Second Prefered color</option>
  82. <option value='R'>Red</option>
  83. <option value='J'>Yellow</option>
  84. <option value='G'>Green</option>
  85. <option value='B'>Blue</option>
  86. </select>
  87. </form>
  88.  
  89.  
  90. <!-- END OF SCRIPT -->
  91. <!/SCRIPT>
  92.  
  93. <!PREVIEW>
  94. <!-- START OF SCRIPT -->
  95.  
  96.  
  97. <!-- HOW TO INSTALL NO DUPLICATES:
  98.  
  99.   1.  Copy code into the HEAD section of document
  100.   2.  Put last coding into the BODY section of document  -->
  101.  
  102. <!-- STEP ONE: Add code into HEAD section of document  -->
  103.  
  104. <HEAD>
  105.  
  106. <SCRIPT LANGUAGE="JavaScript">
  107. <!-- Original:  Denis Dijon (ddijon@hotmail.com) -->
  108. <!-- Web Site:  http://213.177.134.20 -->
  109.  
  110.  
  111.  
  112. <!-- Begin
  113. var OptLstTxt = new Array;
  114. var OptLstVal = new Array;
  115. var OptLen = 0;
  116. function NoDupl(SelObjFrom, SelObjTo) {
  117. var OldToVal = SelObjTo.options[SelObjTo.selectedIndex].value;
  118. if (OptLen == 0) {
  119. OptLen = SelObjFrom.length;
  120. for (var i = 1; i < OptLen; i++) {
  121. OptLstTxt[i] = SelObjFrom.options[i].text;
  122. OptLstVal[i] = SelObjFrom.options[i].value;
  123.    }
  124. }
  125. var j = 1;
  126. for (var i = 1; i < OptLen; i++) {
  127. if (OptLstVal[i] != SelObjFrom.options[SelObjFrom.selectedIndex].value) {
  128. if (j == SelObjTo.length) {
  129. SelObjTo.options[j] = new Option(OptLstTxt[i]);
  130. }
  131. else {
  132. SelObjTo.options[j].text = OptLstTxt[i];
  133. }
  134. SelObjTo.options[j].value = OptLstVal[i];
  135. if (OptLstVal[i] == OldToVal) {
  136. SelObjTo.selectedIndex = j;
  137. }
  138. j++;
  139.    }
  140. }
  141. if (SelObjTo.length > j)
  142. SelObjTo.options[(SelObjTo.length - 1)] = null;
  143. }
  144. //  End -->
  145. </script>
  146.  
  147. </HEAD>
  148.  
  149. <!-- STEP TWO: Add code into BODY section of document  -->
  150.  
  151. <BODY>
  152.  
  153. <form method="POST" name="MForm">
  154. Try to select the same color:
  155. <br>
  156. <select name="Color_1" onChange="NoDupl(this,document.MForm.Color_2)">
  157. <option selected value=''>Select your first prefered color</option>
  158. <option value='R'>Red</option>
  159. <option value='J'>Yellow</option>
  160. <option value='G'>Green</option>
  161. <option value='B'>Blue</option>
  162. </select>
  163. <select name="Color_2" onChange="NoDupl(this,document.MForm.Color_1)">
  164. <option selected value=''>Select Second Prefered color</option>
  165. <option value='R'>Red</option>
  166. <option value='J'>Yellow</option>
  167. <option value='G'>Green</option>
  168. <option value='B'>Blue</option>
  169. </select>
  170. </form>
  171.  
  172. <!-- END OF SCRIPT -->
  173. <!/PREVIEW>
  174.  
  175. <!RELATED>NONE<!/RELATED>
  176.